<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="com.lupus.common.ResourceFactory"%>
<%
String contextPath = request.getContextPath();
%>
<html>
<head>
<link rel=stylesheet href="<%=contextPath%>/jsl/styles/xpage.css" type="text/css">
<link rel=stylesheet href="<%=contextPath%>/jsl/styles/xpops.css" type="text/css">
<script src="<%=contextPath%>/jsl/script/xtool.js" type="text/javascript"></script>
<script src="<%=contextPath%>/jsl/script/xcomm.js" type="text/javascript"></script>
<script src="<%=contextPath%>/jsl/script/xview.js" type="text/javascript"></script>
<script src="<%=contextPath%>/jsl/script/xpops.js" type="text/javascript"></script>
<script type="text/javascript">
function login(){
	var userName = document.all("userName").value;
	var password = document.all("password").value;
	if(userName.length<1||password.length<1){
		window["Comm"].showPopWindow("<%=contextPath%>","common.title.promptinfo","common.tip.usernamepasswordnull",null,null);
		return;
	}
	var requestObject = window["Comm"].buildRequestObject("query","USERNAME,PASSWORD,OID",null,"BAS_USER",null,"USERNAME='"+userName+"'",null,null,null,"LoginInspector");
	requestObject.password = Tool.encrypt(password);
	requestObject.validateCoder =  document.all("validateCoder").value;
	var returnObject = window["Comm"].sendRequest("<%=contextPath%>",requestObject);
	if(returnObject){
		window.location = "<%=contextPath%>/jsp/common/xmain.jsp";
	}else{
		document.all("userName").value = "";
		document.all("password").value = "";
		document.all("validateCoder").value = "";
		document.all("userName").focus();
	}
}
function handleKeyUp(){
	if(event.keyCode==13){
		document.getElementById("loginButton").click();
	}
}
function clearInput(){
	var inputArray = document.getElementsByTagName("INPUT");
	for(var i=0;i<inputArray.length;i++){
		inputArray[i].value = "";
	}
	inputArray[0].focus();
}
window.onload = function(){
	document.body.onselectstart = function(){
		return false;
	};
	document.oncontextmenu = function(){
        return false;
	};
	document.all("userName").focus();
};
</script>
</head>
<body onkeyup = "handleKeyUp()">
<table>
	<tr><td><%=ResourceFactory.getLocalString("common.label.login.username",request)%>&nbsp;</td><td><input name="userName" class="inputstyle"></td></tr>
	<tr><td><%=ResourceFactory.getLocalString("common.label.login.password",request)%>&nbsp;</td><td><input name="password" type="password" class="passwordstyle"></td></tr>
	<tr><td><%=ResourceFactory.getLocalString("common.label.login.validatecoder",request)%>&nbsp;</td><td><input name="validateCoder" type="text" class="validatecoder">&nbsp;&nbsp;<img align="absmiddle" src="<%=contextPath%>/download.jsp?downloadType=image" onclick="this.src=this.src"></img></td></tr>
	<tr><td></td><td align="right"><button onclick="clearInput()" id="clearButton"><%=ResourceFactory.getLocalString("common.button.clear",request)%></button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button onclick="login()" id="loginButton"><%=ResourceFactory.getLocalString("common.button.login",request)%></button></td></tr>
</table>
</body>
</html>